﻿// -------------------------------------------------------------------------
//    @FileName         :    NFServiceSns.cpp
//    @Author           :    gaoyi
//    @Date             :    2025/1/15
//    @Email            :    445267987@qq.com
//    @Module           :    NFServiceSns
//
// -------------------------------------------------------------------------

#include "NFServiceSns.h"

#include <NFPlayer.h>
#include <NFSnsPart.h>
#include <NFComm/NFPluginModule/NFCheck.h>

uint64_t NFServiceSns::GetGuildID(NFPlayer* pPlayer)
{
    CHECK_NULL_RE_VAR_WF(0, pPlayer, 0, "");
    NFSnsPart* pSnsPart  = pPlayer->GetPart<NFSnsPart>(PART_SNS);
    CHECK_NULL_RE_VAR_WF(pPlayer->GetRoleID(), pSnsPart, 0, "");

    return pSnsPart->GetGuildID();
}

std::string NFServiceSns::GetGuildName(NFPlayer* pPlayer)
{
    CHECK_NULL_RE_VAR_WF(0, pPlayer, "", "");
    NFSnsPart* pSnsPart  = pPlayer->GetPart<NFSnsPart>(PART_SNS);
    CHECK_NULL_RE_VAR_WF(pPlayer->GetRoleID(), pSnsPart, "", "");

    return pSnsPart->GetGuildName();
}

bool NFServiceSns::IsInGuild(NFPlayer* pPlayer)
{
    CHECK_NULL_RE_VAR_WF(0, pPlayer, false, "");
    NFSnsPart* pSnsPart  = pPlayer->GetPart<NFSnsPart>(PART_SNS);
    CHECK_NULL_RE_VAR_WF(pPlayer->GetRoleID(), pSnsPart, false, "");

    return pSnsPart->GetGuildID() != 0 && pSnsPart->GetGuildStatus() == EN_GUILD_STATUS_NORMAL;
}

NFSnsPart* NFServiceSns::GetSns(NFPlayer* pPlayer)
{
    CHECK_NULL_RET_VAL(0, pPlayer, nullptr);
    return pPlayer->GetPart<NFSnsPart>();
}

RoleSnsData* NFServiceSns::GetSnsData(NFPlayer* pPlayer)
{
    auto pSnsPart = GetSns(pPlayer);
    CHECK_NULL_RET_VAL(0, pSnsPart, nullptr);
    return pSnsPart->GetData();
}

RoleCorpsData* NFServiceSns::GetRoleCorpsData(NFPlayer* pPlayer)
{
    auto pSnsData = GetSnsData(pPlayer);
    CHECK_NULL_RET_VAL(0, pSnsData, nullptr);
    return &pSnsData->corps_data;
}
